Using Lines To Map NYC’s Bicycle Routes

Cycling in New York City is associated with mixed cycling conditions that include dense urban proximities, relatively flat terrain, congested roadways with “stop-and-go” traffic, and streets with heavy pedestrian activity. The city’s large cycling population includes utility cyclists, such as delivery and messenger services; cycling clubs for recreational cyclists; and increasingly commuters.Cycling is increasingly popular in New York City; in 2017 there were approximately 450,000 daily bike trips, compared with 170,000 daily bike trips in 2005.

bike_routes <- readOGR("C:/Users/prakh/Documents/GitHub/Homework2-prakharm/Bicycle Routes.geojson")
## OGR data source with driver: GeoJSON 
## Source: "C:\Users\prakh\Documents\GitHub\Homework2-prakharm\Bicycle Routes.geojson", layer: "Bicycle Routes"
## with 16672 features
## It has 15 fields
plot(bike_routes)

leaflet() %>%
  addProviderTiles("OpenStreetMap.HOT") %>%
  addPolylines(data = bike_routes)

Using Polygons To Plot NYC’s School Zones

2019-2020 School Year

Middle schools serve children in grades 6-8. Every fall, all fifth graders enrolled in a New York City public elementary school receive customized middle school applications. The application has all the middle schools where each student is eligible to apply. Students complete the application by ranking the schools in order of preference and return the application to their current school. Applications must be submitted in or before December and decision letters are available in the late spring.

Children living beyond walking distance from their school may qualify to receive free MetroCard for transportation.

school_zones <- readOGR("C:/Users/prakh/Documents/GitHub/Homework2-prakharm/2019-2020 School Zones (Middle School).geojson")
## OGR data source with driver: GeoJSON 
## Source: "C:\Users\prakh\Documents\GitHub\Homework2-prakharm\2019-2020 School Zones (Middle School).geojson", layer: "2019-2020 School Zones (Middle School)"
## with 334 features
## It has 13 fields
plot(school_zones)

leaflet() %>%
  addProviderTiles("OpenStreetMap.HOT") %>%
  addPolygons(data = school_zones)

Parking Meters in NYC

Summary & Quick Facts:

parking_meter <-read.csv("C:/Users/prakh/Documents/GitHub/Homework2-prakharm/dot_MUNIMETER_20191001.csv")

#designing a custom palette
pallete <- colorFactor(c("#3a981a","#98271a","#271a98","#98901a","#981a98"), c("Inactive", "Active","Retired","Planned","Removed"))

#plotting the map
leaflet() %>%
  addProviderTiles("OpenStreetMap.HOT") %>%
  addCircleMarkers(data = parking_meter, lng = ~LONG, lat = ~LAT, radius = 1.5, color = ~pallete(Status)) %>%
  addLegend(position = "topright" , pal = pallete, values = parking_meter$Status, title = "Status")

The ubiquitous Muni-meters we see today are actually quite new. The Department of Transportation in the early 2010s replaced the last remaining single-space coin activated parking meters. The reason? The newer Muni-meters have several advantages over the old school parking meters your Uncle Tony remembers. They include a convenient digital pay-and-display system, the reduction of unnecessary sidewalk encumbrances, and additional capacity for parked cars in the same curb space.

outline <- parking_meter[chull(parking_meter$LONG,parking_meter$LAT),]

multi_layer_map <- leaflet(parking_meter) %>%
       # Base groups
      addTiles(group = "OSM (default)") %>%
      addProviderTiles(providers$Stamen.Toner, group = "Toner") %>%
      addProviderTiles(providers$Stamen.Watercolor, group = "Watercolor") %>%
      addProviderTiles(providers$Stamen.Terrain, group = "Terrain") %>%
      # Overlay groups
      addCircleMarkers(data = parking_meter, lng = ~LONG, lat = ~LAT, radius = 1.5, color = ~pallete(Status),group = "Parking Meters") %>%
  addLegend(position = "topright" , pal = pallete, values = parking_meter$Status, title = "Status") %>%
      addPolygons(data = outline, lng = ~LONG, lat = ~LAT,
      fill = F, weight = 2, color = "#0c17eb", group = "City Outline") %>%
      # Layers control
      addLayersControl(
     baseGroups = c("OSM (default)", "Toner", "Watercolor","Terrain"),
     overlayGroups = c("Parking Meters", "City Outline"),
     options = layersControlOptions(collapsed = FALSE)
  )

multi_layer_map